package com.example.mapp;

import com.example.entity.demandMaintance.DemandMaintanceApply;
import com.example.mapp.buildSql.DemandMaintAppSql;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface DemandMaintMapp {

    @SelectProvider(type = DemandMaintAppSql.class,method = "queryDemandMaints")
    List<DemandMaintanceApply> query(DemandMaintanceApply demandMaintanceApply) throws Exception;

    @UpdateProvider(type = DemandMaintAppSql.class,method = "updateDemandMaint")
    int update(Map map) throws Exception;

    @Insert("INSERT INTO demand_maintance_apply (apply_status, end_date, have_insurance, have_test_system, " +
            "maintenance_cycle,maintenance_party_id, maintenance_party_name, start_date, user_party_id, " +
            "user_party_name, other_notes, parent_party_id,parent_parent_party_id,create_company_name,insurance_name,insurance_date,elevator_ids) " +
            " VALUES (#{applyStatus}, #{endDate}, #{haveInsurance}, #{haveTestSystem}, #{maintenanceCycle}, " +
            "#{maintenancePartyId}, #{maintenancePartyName}, #{startDate}, #{userPartyId}, #{userPartyName}," +
            " #{otherNotes}, #{parentPartyId}, #{parentParentPartyId}, #{createCompanyName},#{insuranceName},#{insuranceDate},#{elevatorIds})")
    @SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id",before = false,resultType = Long.class)
    int insert(DemandMaintanceApply demandMaintanceApply) throws Exception;

    @Delete("delete from demand_maintance_apply where id=#{id}")
    int delete(String id) throws  Exception;

}
